package org.example;

import dao.UserDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import service.BookService;

/**
 * 了解生命周期
 */

public class APP3 {
    public static void main(String[] args) {
        //1, 获取Ioc容器
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        //2. 我想拿service层的类对象怎么办；因为它里面嵌套了一个dao；是因为我们在xml里配置了它俩的关系
        BookService bookService = (BookService) ctx.getBean("bookService");
        bookService.save();
        ctx.registerShutdownHook();
    }
}
